home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / aaa < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  50.2 KB

  1. Subject: aaa - the amazing awk assembler
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 4, Issue 76
  6. Submitted by: decvax!utzoo!henry
  7.  
  8. "aaa" (the Amazing Awk Assembler) is a primitive assembler written entirely
  9. in awk and sed.  It was done for fun, to establish whether it was possible.
  10. It is; it works.  It's quite slow, the input syntax is eccentric and rather
  11. restricted, and error-checking is virtually nonexistent, but it does work.
  12. Furthermore it's very easy to adapt to a new machine, provided the machine
  13. falls into the generic "8-bit-micro" category.  It is supplied "as is",
  14. with no guarantees of any kind.  I can't be bothered to do any more work on
  15. it right now, but even in its imperfect state it may be useful to someone.
  16.  
  17. #! /bin/sh
  18. # This is a shell archive, meaning:
  19. # 1. Remove everything above the #! /bin/sh line.
  20. # 2. Save the resulting text in a file.
  21. # 3. Execute the file with /bin/sh (not csh) to create the files:
  22. #    M_README
  23. #    README
  24. #    Makefile
  25. #    aaa
  26. #    abst
  27. #    anon
  28. #    aux
  29. #    try.s
  30. #    try.x.good
  31. #    01pgm.s
  32. #    01pgm.x.good
  33. #    6801
  34. #    6809
  35. # This archive created: Tue Apr 22 09:57:43 1986
  36. export PATH; PATH=/bin:$PATH
  37. echo shar: extracting "'M_README'" '(711 characters)'
  38. if test -f 'M_README'
  39. then
  40.     echo shar: will not over-write existing file "'M_README'"
  41. else
  42. cat << \SHAR_EOF > 'M_README'
  43.                        ** Moderator's Readme **
  44.  
  45. I was able to get the "aaa" program to run on ULTRIX (BSD4.2), with a
  46. few minor problems.  My system does not have the "getopt" program, so I
  47. had to comment out line 7 of the aaa script (this makes it impossible
  48. to enter dash options, if you really need those options and don't have
  49. getopt(1), you can change the script to parse for them yourself.)  I
  50. also found that "awk" lived on a different directory on our system
  51. "/usr/local", so I had to change line 1 of aaa to include that in the
  52. PATH.
  53.  
  54. John P. Nelson, Moderator, mod.sources
  55. (decvax!genrad!panda!jpn  seismo!harvard!wjh12!panda!jpn)
  56. Send source code to panda!sources, requests to panda!sources-request
  57. SHAR_EOF
  58. if test 711 -ne "`wc -c < 'M_README'`"
  59. then
  60.     echo shar: error transmitting "'M_README'" '(should have been 711 characters)'
  61. fi
  62. fi
  63. echo shar: extracting "'README'" '(2506 characters)'
  64. if test -f 'README'
  65. then
  66.     echo shar: will not over-write existing file "'README'"
  67. else
  68. cat << \SHAR_EOF > 'README'
  69. "aaa" (the Amazing Awk Assembler) is a primitive assembler written entirely
  70. in awk and sed.  It was done for fun, to establish whether it was possible.
  71. It is; it works.  It's quite slow, the input syntax is eccentric and rather
  72. restricted, and error-checking is virtually nonexistent, but it does work.
  73. Furthermore it's very easy to adapt to a new machine, provided the machine
  74. falls into the generic "8-bit-micro" category.  It is supplied "as is",
  75. with no guarantees of any kind.  I can't be bothered to do any more work on
  76. it right now, but even in its imperfect state it may be useful to someone.
  77.  
  78. aaa is the mainline shell file.
  79.  
  80. aux is a subdirectory with machine-independent stuff.  Anon, 6801, and
  81. 6809 are subdirectories with machine-dependent stuff, choice specified
  82. by a -m option (default is "anon").  Actually, even the stuff that is
  83. supposedly machine-independent does have some machine-dependent
  84. assumptions; notably, it knows that bytes are 8 bits (not serious) and
  85. that the byte is the basic unit of instructions (more serious).  These
  86. would have to change for the 68000 (going to 16-bit "bytes" might be
  87. sufficient) and maybe for the 32016 (harder).
  88.  
  89. aaa thinks that the machine subdirectories and the aux subdirectory are
  90. in the current directory, which is almost certainly wrong.
  91.  
  92. abst is an abstract for a paper.  "card", in each machine directory,
  93. is a summary card for the slightly-eccentric input language.  There is no
  94. real manual at present; sorry.
  95.  
  96. try.s is a sample piece of 6809 input; it is semantic trash, purely for
  97. test purposes.  The assembler produces try.a, try.defs, and try.x as
  98. outputs from "aaa try.s".  try.a is an internal file that looks
  99. somewhat like an assembly listing.  try.defs is another internal file
  100. that looks somewhat like a symbol table.  These files are preserved
  101. because of possible usefulness; tmp[123] are non-preserved temporaries.
  102. try.x is the Intel-hex output.  try.x.good is identical to try.x and is a
  103. saved copy for regression testing of new work.
  104.  
  105. 01pgm.s is a self-programming program for a 68701, based on the one
  106. in the Motorola ap note.  01pgm.x.good is another regression-test file.
  107.  
  108. If your C library (used by awk) has broken "%02x" so it no longer means
  109. "two digits of hex, *zero-filled*" (as some SysV libraries have), you
  110. will have to fall back from aux/hex to aux/hex.argh, which does it the
  111. hard way.  Oh yes, you'll note that aaa feeds settings into awk on the
  112. command line; don't assume your awk won't do this until you try it.
  113. SHAR_EOF
  114. if test 2506 -ne "`wc -c < 'README'`"
  115. then
  116.     echo shar: error transmitting "'README'" '(should have been 2506 characters)'
  117. fi
  118. fi
  119. echo shar: extracting "'Makefile'" '(270 characters)'
  120. if test -f 'Makefile'
  121. then
  122.     echo shar: will not over-write existing file "'Makefile'"
  123. else
  124. cat << \SHAR_EOF > 'Makefile'
  125. # Regression test.
  126. r:    aaa 01pgm.s try.s
  127.     aaa 01pgm.s
  128.     cmp 01pgm.x 01pgm.x.good
  129.     aaa try.s
  130.     cmp try.x try.x.good
  131.  
  132. clean:
  133.     rm -f *.a *.defs *.x junk* tmp? dtr
  134.  
  135. dtr:
  136.     makedtr README Makefile 01pgm.s 01pgm.x.good 6801/* 6809/* aaa \
  137.     abst anon/* aux/* try.s try.x.good >dtr
  138. SHAR_EOF
  139. if test 270 -ne "`wc -c < 'Makefile'`"
  140. then
  141.     echo shar: error transmitting "'Makefile'" '(should have been 270 characters)'
  142. fi
  143. fi
  144. echo shar: extracting "'aaa'" '(2004 characters)'
  145. if test -f 'aaa'
  146. then
  147.     echo shar: will not over-write existing file "'aaa'"
  148. else
  149. cat << \SHAR_EOF > 'aaa'
  150. PATH=/bin:/usr/bin ; export PATH
  151.  
  152. machdir=.        # Directory holding machine definitions.
  153. machine=anon        # Default machine.
  154. lib=aux            # Directory holding machine-independent auxiliaries.
  155.  
  156. set -- `getopt 'm:s:o:' $*`
  157. if test $? != 0
  158. then
  159.     echo 'Usage: aaa [-m machine] [-s startaddr] [-o offset] [file] ...' >&2
  160.     exit 2
  161. fi
  162. for f
  163. do
  164.     case "$f"
  165.     in
  166.         -s)        # Runtime start address.
  167.         startaddr="$2"
  168.         shift
  169.         shift
  170.         ;;
  171.  
  172.         -o)        # Offset for code location counter.
  173.         offset="$2"
  174.         shift
  175.         shift
  176.         ;;
  177.  
  178.         -m)        # Machine.
  179.         machine="$2"
  180.         shift
  181.         shift
  182.         ;;
  183.  
  184.         --)
  185.         shift ; break
  186.         ;;
  187.     esac
  188. done
  189.  
  190. for f
  191. do
  192.     echo "$f:"
  193.     bn=`basename $f .s`
  194.     # Do we have a machine specification in the file?
  195.     machline=`sed 1q $f`
  196.     case "$machline"
  197.     in
  198.         '#m'*)
  199.         machine=`expr "x$machline" : 'x#m[     ]\(.*\)'`
  200.         ;;
  201.     esac
  202.     # Is our machine specification valid?
  203.     if test -d $machdir/$machine
  204.     then
  205.         machine=$machdir/$machine
  206.     elif test ! -d $machine
  207.     then
  208.         echo "aaa: unknown machine $machine" >&2
  209.         exit 1
  210.     fi
  211.     # Unsugar the syntax, change to one byte/line, do base conversions,
  212.     # cope with machine-specific notation, and assign addresses to code
  213.     # and values to symbols.
  214.     sed -f $lib/unsugar $f | tr -s '     ;' '\012' | awk -f $lib/base |
  215.         awk -f $machine/notn | awk -f $lib/defs >tmp1
  216.     # Get symbol definitions, merge with the predefined symbols.
  217.     sed -n '/=/s//    /p' tmp1 >$bn.defs
  218.     sort $machine/predef $bn.defs >tmp2
  219.     # Get code lines, sort by contents.
  220.     egrep '    ' tmp1 | sort +1 >tmp3
  221.     # Plug definitions into code, sort by location again, postprocess
  222.     # for byte extraction and PC-relative offset arithmetic.
  223.     join -a1 -j1 2 -o 1.1 2.2 1.2 '-t    ' tmp3 tmp2 | sort -n |
  224.         awk -f $machine/final >$bn.a
  225.     # Make a feeble attempt to detect errors.
  226.     awk '$2 !~ /^[0-9]+$/ || $2 < 0 || $2 > 255' $bn.a
  227.     # Finally, turn into hex.  The "0\t0" is a kludge to cause a
  228.     # buffer flush at the end.
  229.     (cat $bn.a ; echo '0    0') |
  230.         awk -f $lib/hex start=$startaddr offset=$offset - |
  231.         tr 'a-f' 'A-F' >$bn.x
  232.     # Clean up.
  233.     rm tmp1 tmp2 tmp3
  234. done
  235. SHAR_EOF
  236. if test 2004 -ne "`wc -c < 'aaa'`"
  237. then
  238.     echo shar: error transmitting "'aaa'" '(should have been 2004 characters)'
  239. fi
  240. chmod +x 'aaa'
  241. fi
  242. echo shar: extracting "'abst'" '(530 characters)'
  243. if test -f 'abst'
  244. then
  245.     echo shar: will not over-write existing file "'abst'"
  246. else
  247. cat << \SHAR_EOF > 'abst'
  248. .TL
  249. Writing Assemblers With Awk And Sed
  250. .AU
  251. Henry Spencer
  252. .AI
  253. .ZO
  254. (416)978-6060
  255. utzoo!henry
  256. .AB
  257. Simple assemblers can be written using the shell, \fIawk\fR, and \fIsed\fR,
  258. with no C code whatsoever.
  259. They accept a fairly conventional input
  260. language, and produce Intel hex output.
  261. (True binary output would require a C program for the final conversion
  262. to binary.)
  263. They run quite slowly, their input language is restrictive and contrived,
  264. and error checking is almost totally absent,
  265. but they are quick and easy to write and change.
  266. SHAR_EOF
  267. if test 530 -ne "`wc -c < 'abst'`"
  268. then
  269.     echo shar: error transmitting "'abst'" '(should have been 530 characters)'
  270. fi
  271. fi
  272. if test ! -d 'anon'
  273. then
  274.     echo shar: creating directory "'anon'"
  275.     mkdir 'anon'
  276. fi
  277. echo shar: extracting "'anon/card'" '(558 characters)'
  278. if test -f 'anon/card'
  279. then
  280.     echo shar: will not over-write existing file "'anon/card'"
  281. else
  282. cat << \SHAR_EOF > 'anon/card'
  283. #m anon    what machine this is for (first line only)
  284. #foo    comment
  285. x;y    two successive bytes
  286. x y    two successive bytes
  287. 07    octal
  288. 0x7    hex
  289. 'c    character constant
  290. '\n    ditto
  291. foo:    label
  292. x=100    definition (numbers only)
  293. .=100    setting location counter (numbers only)
  294. .=.+5    bumping location counter (numbers only)
  295. .text    what it says
  296. .data    ditto
  297. .bss    ditto
  298. =thing    two-byte constant
  299. /thing    lower byte of 16-bit thing
  300. \thing    upper byte of 16-bit thing
  301. %thing    lower byte of 16-bit thing as an offset relative to PC
  302. %%thing    upper byte of 16-bit thing as an offset relative to PC
  303. SHAR_EOF
  304. if test 558 -ne "`wc -c < 'anon/card'`"
  305. then
  306.     echo shar: error transmitting "'anon/card'" '(should have been 558 characters)'
  307. fi
  308. fi
  309. echo shar: extracting "'anon/final'" '(1299 characters)'
  310. if test -f 'anon/final'
  311. then
  312.     echo shar: will not over-write existing file "'anon/final'"
  313. else
  314. cat << \SHAR_EOF > 'anon/final'
  315. # Final postprocessing, to handle high/low byte-extraction operators,
  316. # and compute PC-relative offsets.  The only thing that is really
  317. # machine-dependent here is the pcbias's, which reflect the difference
  318. # between the location of an offset byte and the PC which should be
  319. # used in computing it (i.e., how far ahead the PC is by the time the
  320. # byte is used to alter the PC).
  321. BEGIN {
  322.     FS = "\t"
  323.     OFS = "\t"
  324.     pcbiaslo = 0
  325.     pcbiashi = 0
  326.     if (pcbiaslo > pcbiashi)
  327.         pcbiasmax = pcbiaslo
  328.     else
  329.         pcbiasmax = pcbiashi
  330. }
  331. {
  332.     if ($2 == "") {            # Number or something, not symbol.
  333.         if ($3 ~ /^\/[0-9]/) {
  334.             it = substr($3, 2);
  335.             while (it < 0)
  336.                 it += 65536
  337.             print $1, int(it%256 + 0.001), "# " $3
  338.         } else if ($3 ~ /^\\[0-9]/) {
  339.             it = substr($3, 2);
  340.             while (it < 0)
  341.                 it += 65536
  342.             print $1, int(it/256 + 0.001), "# " $3
  343.         } else
  344.             print $1, $3
  345.     } else if ($2 ~ /^[0-9]+$/)    # Symbol, ordinary value.
  346.         print $1, $2, "# " $3
  347.     else if ($2 ~ /%$/) {        # Symbol, PC-relative value.
  348.         base = substr($1, 1, length($1)-1)
  349.         it = substr($2, 2, length($2)-2)
  350.         p = it - base
  351.         while (p < pcbiasmax)
  352.             p += 65536
  353.         if ($2 ~ /^\//)
  354.             print $1, int((p - pcbiaslo)%256 + 0.001), "# " $3
  355.         else
  356.             print $1, int((p - pcbiashi)/256 + 0.001), "# " $3
  357.     } else                # Something else.
  358.         print $1, $2, "# " $3
  359. }
  360. SHAR_EOF
  361. if test 1299 -ne "`wc -c < 'anon/final'`"
  362. then
  363.     echo shar: error transmitting "'anon/final'" '(should have been 1299 characters)'
  364. fi
  365. fi
  366. echo shar: extracting "'anon/notn'" '(279 characters)'
  367. if test -f 'anon/notn'
  368. then
  369.     echo shar: will not over-write existing file "'anon/notn'"
  370. else
  371. cat << \SHAR_EOF > 'anon/notn'
  372. # Main preprocessing, some more-or-less machine-independent odds and ends
  373. # (two-byte constants (note byte order known)).
  374. /^=/ {                # Two-byte constant, low byte first.
  375.     print "/" substr($0, 2)
  376.     print "\\" substr($0, 2)
  377.     next
  378. }
  379. /./ { print }            # Something else, leave untouched.
  380. SHAR_EOF
  381. if test 279 -ne "`wc -c < 'anon/notn'`"
  382. then
  383.     echo shar: error transmitting "'anon/notn'" '(should have been 279 characters)'
  384. fi
  385. fi
  386. echo shar: extracting "'anon/predef'" '(0 character)'
  387. if test -f 'anon/predef'
  388. then
  389.     echo shar: will not over-write existing file "'anon/predef'"
  390. else
  391. cat << \SHAR_EOF > 'anon/predef'
  392. SHAR_EOF
  393. if test 0 -ne "`wc -c < 'anon/predef'`"
  394. then
  395.     echo shar: error transmitting "'anon/predef'" '(should have been 0 character)'
  396. fi
  397. fi
  398. echo shar: done with directory "'anon'"
  399. if test ! -d 'aux'
  400. then
  401.     echo shar: creating directory "'aux'"
  402.     mkdir 'aux'
  403. fi
  404. echo shar: extracting "'aux/base'" '(2362 characters)'
  405. if test -f 'aux/base'
  406. then
  407.     echo shar: will not over-write existing file "'aux/base'"
  408. else
  409. cat << \SHAR_EOF > 'aux/base'
  410. BEGIN {
  411.     # Hex/octal conversion table.
  412.     hex["0"] = 0
  413.     hex["1"] = 1
  414.     hex["2"] = 2
  415.     hex["3"] = 3
  416.     hex["4"] = 4
  417.     hex["5"] = 5
  418.     hex["6"] = 6
  419.     hex["7"] = 7
  420.     hex["8"] = 8
  421.     hex["9"] = 9
  422.     hex["a"] = 10
  423.     hex["b"] = 11
  424.     hex["c"] = 12
  425.     hex["d"] = 13
  426.     hex["e"] = 14
  427.     hex["f"] = 15
  428.     hex["A"] = 10
  429.     hex["B"] = 11
  430.     hex["C"] = 12
  431.     hex["D"] = 13
  432.     hex["E"] = 14
  433.     hex["F"] = 15
  434.     # ASCII conversion tables.
  435.     ascii = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  436.     ascii = ascii "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  437.     conv["n"] = 10
  438.     conv["b"] = 8
  439.     conv["t"] = 9
  440.     conv["r"] = 13
  441.     conv["v"] = 11
  442.     conv["f"] = 12
  443.     conv["a"] = 7
  444. }
  445. /0[xX]?[0-9a-fA-F]/ || /'/ {
  446.     out = $0
  447.     place = 1
  448.     len = length(out)
  449.     while (place <= len) {
  450.         if (substr(out, place, 1) ~ /[a-zA-Z_]/) {
  451.             # Identifier, may contain digits, skip past it.
  452.             i = place+1
  453.             while (i <= len) {
  454.                 char = substr(out, i, 1)
  455.                 if (char !~ /[a-zA-Z0-9_]/)
  456.                     break;
  457.                 i++
  458.             }
  459.             place = i
  460.         } else if (substr(out, place, 1) == "'") {
  461.             # Character constant.
  462.             ch = substr(out, place+1, 1)
  463.             i = place + 2
  464.             if (ch == "\\")    {
  465.                 number = conv[substr(out, place+2, 1)]
  466.                 i++
  467.             } else {
  468.                 ind = index(ascii, ch)
  469.                 if (ind > 0)
  470.                     number = ind + 31
  471.                 else
  472.                     number = ""
  473.             }
  474.             if (number == "")
  475.                 number = 32
  476.             first = substr(out, 1, place-1)
  477.             last = substr(out, i)
  478.             out = first number last
  479.             len = length(out)
  480.             place = len - length(last) + 1
  481.         } else if (substr(out, place) ~ /^0[xX][0-9a-fA-F]+/) {
  482.             # Hex.
  483.             total = 0
  484.             i = place+2
  485.             while (i <= len) {
  486.                 digit = substr(out, i, 1)
  487.                 if (digit !~ /[0-9a-fA-F]/)
  488.                     break;
  489.                 total = total*16 + hex[digit]
  490.                 i++
  491.             }
  492.             first = substr(out, 1, place-1)
  493.             last = substr(out, i)
  494.             # out = first total last
  495.             out = sprintf("%s%.0f%s", first, total, last)
  496.             len = length(out)
  497.             place = len - length(last) + 1
  498.         } else if (substr(out, place) ~ /^0[0-7]+/) {
  499.             # Octal.
  500.             total = 0
  501.             i = place+1
  502.             while (i <= len) {
  503.                 digit = substr(out, i, 1)
  504.                 if (digit !~ /[0-7]/)
  505.                     break;
  506.                 total = total*8 + hex[digit]
  507.                 i++
  508.             }
  509.             first = substr(out, 1, place-1)
  510.             last = substr(out, i)
  511.             # out = first total last
  512.             out = sprintf("%s%.0f%s", first, total, last)
  513.             len = length(out)
  514.             place = len - length(last) + 1
  515.         } else
  516.             # Something else, ignore.
  517.             place++
  518.     }
  519.     print out
  520.     next
  521. }
  522. /./ { print }
  523. SHAR_EOF
  524. if test 2362 -ne "`wc -c < 'aux/base'`"
  525. then
  526.     echo shar: error transmitting "'aux/base'" '(should have been 2362 characters)'
  527. fi
  528. fi
  529. echo shar: extracting "'aux/defs'" '(1110 characters)'
  530. if test -f 'aux/defs'
  531. then
  532.     echo shar: will not over-write existing file "'aux/defs'"
  533. else
  534. cat << \SHAR_EOF > 'aux/defs'
  535. # The heart of the assembler, interpreting definitions, keeping location
  536. # counters, and assigning addresses to code.
  537. BEGIN { locs["d"] = 0 ; locs["b"] = 0; locs["t"] = 0; which = "d" }
  538. /^[^.].*=.+$/ {            # Symbol definition.
  539.     n = split($0, bits, "=")
  540.     it = bits[2]
  541.     while (it < 0)
  542.         it += 65536
  543.     print bits[1] "=" it
  544.     print "/" bits[1] "=" int(it%256 + 0.001)
  545.     print "\\" bits[1] "=" int(it/256 + 0.001)
  546.     print "%" bits[1] "=" "/" bits[2] "%"
  547.     print "%%" bits[1] "=" "\\" bits[2] "%"
  548. }
  549. /^\.=[0-9]+$/ {            # Set location counter.
  550.     locs[which] = substr($0, 3)
  551. }
  552. /^\.=\.\+[0-9]+$/ {        # Bump location counter, allocating space.
  553.     locs[which] += substr($0, 5)
  554. }
  555. /:/ {                # Label.
  556.     n = split($0, bits, ":")
  557.     print bits[1] "=" locs[which]
  558.     print "/" bits[1] "=" int(locs[which]%256 + 0.001)
  559.     print "\\" bits[1] "=" int(locs[which]/256 + 0.001)
  560.     print "%" bits[1] "=" "/" locs[which] "%"
  561.     print "%%" bits[1] "=" "\\" locs[which] "%"
  562. }
  563. /^\.text$/ {
  564.     which = "t"
  565. }
  566. /^\.data$/ {
  567.     which = "d"
  568. }
  569. /^\.bss$/ {
  570.     which = "b"
  571. }
  572. /^$/    { next }
  573. $0 !~ /[=:]/ && $0 !~ /^\./ {    # Code.
  574.     print locs[which] which "\t" $0
  575.     locs[which]++
  576. }
  577. SHAR_EOF
  578. if test 1110 -ne "`wc -c < 'aux/defs'`"
  579. then
  580.     echo shar: error transmitting "'aux/defs'" '(should have been 1110 characters)'
  581. fi
  582. fi
  583. echo shar: extracting "'aux/hex'" '(2010 characters)'
  584. if test -f 'aux/hex'
  585. then
  586.     echo shar: will not over-write existing file "'aux/hex'"
  587. else
  588. cat << \SHAR_EOF > 'aux/hex'
  589. # Convert to Intel hex format.  Input lines should have location first
  590. # and then one-byte decimal value, separated by tabs; any further stuff
  591. # on the line is ignored.  Blank lines are ignored, as are lines starting
  592. # with white space followed by a '#'.  If the awk variable "offset" is
  593. # non-empty, it's the (decimal) offset for the location counter (so code
  594. # assembled to go at location 010000 can start at 0 for purposes of
  595. # PROM blowing and such).  If "startaddr" is non-empty, it's the start
  596. # address to go in the terminator record.
  597. #
  598. # Annoying botch:  to avoid repeating all the buffer-flush code twice
  599. # (laziness on my part), the last line of input should be "0\t0" or
  600. # something like that (i.e., valid-looking input with an out-of-sequence
  601. # location) to cause a flush.
  602. BEGIN {
  603.     FS = "\t"
  604.     nbytes = 0
  605.     loc = 0
  606.     if (offset == "")
  607.         offset = 0
  608.     if (start == "")
  609.         start = 0
  610.     hex[0] = "0"
  611.     hex[1] = "1"
  612.     hex[2] = "2"
  613.     hex[3] = "3"
  614.     hex[4] = "4"
  615.     hex[5] = "5"
  616.     hex[6] = "6"
  617.     hex[7] = "7"
  618.     hex[8] = "8"
  619.     hex[9] = "9"
  620.     hex[10] = "A"
  621.     hex[11] = "B"
  622.     hex[12] = "C"
  623.     hex[13] = "D"
  624.     hex[14] = "E"
  625.     hex[15] = "F"
  626. }
  627. /^$/ { next }
  628. /^[     ]*#/ { next }
  629. {
  630.     byteloc = substr($1, 1, length($1)-1)
  631.     if (byteloc != loc+nbytes || nbytes >= 8) {
  632.         if (nbytes > 0) {
  633.             lochi = int((loc+offset)/256 + 0.001)
  634.             loclo = int((loc+offset)%256 + 0.001)
  635.             locx = sprintf("%02x%02x", lochi, loclo)
  636.             cs += nbytes + lochi + loclo
  637.             while (cs > 255)
  638.                 cs -= 256
  639.             cs = -cs
  640.             if (cs < 0)
  641.                 cs += 256
  642.             csx = sprintf("%02x", cs)
  643.             print ":0" hex[nbytes] locx "00" datax csx
  644.         }
  645.         nbytes = 0
  646.         datax = ""
  647.         loc = byteloc
  648.         cs = 0
  649.     }
  650.     nbytes++
  651.     it = $2
  652.     if (it < 0)
  653.         it += 256
  654.     cs += it
  655.     datax = sprintf("%s%02x", datax, it);
  656. }
  657. END {
  658.     starthi = int((start+offset)/256 + 0.001)
  659.     startlo = int((start+offset)%256 + 0.001)
  660.     startx = sprintf("%02x%02x", starthi, startlo)
  661.     cs = starthi + startlo + 1
  662.     while (cs > 255)
  663.         cs -= 256
  664.     cs = -cs
  665.     if (cs < 0)
  666.         cs += 256
  667.     csx = sprintf("%02x", cs)
  668.     print ":00" startx "01" csx
  669. }
  670. SHAR_EOF
  671. if test 2010 -ne "`wc -c < 'aux/hex'`"
  672. then
  673.     echo shar: error transmitting "'aux/hex'" '(should have been 2010 characters)'
  674. fi
  675. fi
  676. echo shar: extracting "'aux/hex.argh'" '(2272 characters)'
  677. if test -f 'aux/hex.argh'
  678. then
  679.     echo shar: will not over-write existing file "'aux/hex.argh'"
  680. else
  681. cat << \SHAR_EOF > 'aux/hex.argh'
  682. # Convert to Intel hex format.  Input lines should have location first
  683. # and then one-byte decimal value, separated by tabs; any further stuff
  684. # on the line is ignored.  Blank lines are ignored, as are lines starting
  685. # with white space followed by a '#'.  If the awk variable "offset" is
  686. # non-empty, it's the (decimal) offset for the location counter (so code
  687. # assembled to go at location 010000 can start at 0 for purposes of
  688. # PROM blowing and such).  If "startaddr" is non-empty, it's the start
  689. # address to go in the terminator record.
  690. #
  691. # Annoying botch:  to avoid repeating all the buffer-flush code twice
  692. # (laziness on my part), the last line of input should be "0\t0" or
  693. # something like that (i.e., valid-looking input with an out-of-sequence
  694. # location) to cause a flush.
  695. BEGIN {
  696.     FS = "\t"
  697.     nbytes = 0
  698.     loc = 0
  699.     if (offset == "")
  700.         offset = 0
  701.     if (start == "")
  702.         start = 0
  703.     hex[0] = "0"
  704.     hex[1] = "1"
  705.     hex[2] = "2"
  706.     hex[3] = "3"
  707.     hex[4] = "4"
  708.     hex[5] = "5"
  709.     hex[6] = "6"
  710.     hex[7] = "7"
  711.     hex[8] = "8"
  712.     hex[9] = "9"
  713.     hex[10] = "A"
  714.     hex[11] = "B"
  715.     hex[12] = "C"
  716.     hex[13] = "D"
  717.     hex[14] = "E"
  718.     hex[15] = "F"
  719. }
  720. /^$/ { next }
  721. /^[     ]*#/ { next }
  722. {
  723.     byteloc = substr($1, 1, length($1)-1)
  724.     if (byteloc != loc+nbytes || nbytes >= 8) {
  725.         if (nbytes > 0) {
  726.             lochi = int((loc+offset)/256 + 0.001)
  727.             loclo = int((loc+offset)%256 + 0.001)
  728.             lochx = hex[int(lochi/16+0.01)] hex[int(lochi%16+0.01)]
  729.             loclx = hex[int(loclo/16+0.01)] hex[int(loclo%16+0.01)]
  730.             locx = lochx loclx
  731.             cs += nbytes + lochi + loclo
  732.             while (cs > 255)
  733.                 cs -= 256
  734.             cs = -cs
  735.             if (cs < 0)
  736.                 cs += 256
  737.             csx = hex[int(cs/16+0.01)] hex[int(cs%16+0.01)]
  738.             print ":0" hex[nbytes] locx "00" datax csx
  739.         }
  740.         nbytes = 0
  741.         datax = ""
  742.         loc = byteloc
  743.         cs = 0
  744.     }
  745.     nbytes++
  746.     it = $2
  747.     if (it < 0)
  748.         it += 256
  749.     cs += it
  750.     datax = datax hex[int(it/16+0.01)] hex[int(it%16+0.01)]
  751. }
  752. END {
  753.     starthi = int((start+offset)/256 + 0.001)
  754.     startlo = int((start+offset)%256 + 0.001)
  755.     starthx = hex[int(starthi/16+0.01)] hex[int(starthi%16+0.01)]
  756.     startlx = hex[int(startlo/16+0.01)] hex[int(startlo%16+0.01)]
  757.     startx = starthx startlx
  758.     cs = starthi + startlo + 1
  759.     while (cs > 255)
  760.         cs -= 256
  761.     cs = -cs
  762.     if (cs < 0)
  763.         cs += 256
  764.     csx = hex[int(cs/16+0.01)] hex[int(cs%16+0.01)]
  765.     print ":00" startx "01" csx
  766. }
  767. SHAR_EOF
  768. if test 2272 -ne "`wc -c < 'aux/hex.argh'`"
  769. then
  770.     echo shar: error transmitting "'aux/hex.argh'" '(should have been 2272 characters)'
  771. fi
  772. fi
  773. echo shar: extracting "'aux/unsugar'" '(133 characters)'
  774. if test -f 'aux/unsugar'
  775. then
  776.     echo shar: will not over-write existing file "'aux/unsugar'"
  777. else
  778. cat << \SHAR_EOF > 'aux/unsugar'
  779. # Dispense with comments and white space around =.  Ensure a byte
  780. # separator after :.
  781. s/#.*//
  782. /=/s/[     ][     ]*=[     ][     ]*/=/g
  783. s/:/:;/g
  784. SHAR_EOF
  785. if test 133 -ne "`wc -c < 'aux/unsugar'`"
  786. then
  787.     echo shar: error transmitting "'aux/unsugar'" '(should have been 133 characters)'
  788. fi
  789. fi
  790. echo shar: done with directory "'aux'"
  791. echo shar: extracting "'try.s'" '(217 characters)'
  792. if test -f 'try.s'
  793. then
  794.     echo shar: will not over-write existing file "'try.s'"
  795. else
  796. cat << \SHAR_EOF > 'try.s'
  797. #m 6809
  798. glop = 100
  799.  
  800. .data
  801. .=200
  802. it:    =1024
  803.     067
  804.     77
  805.  
  806. .text
  807. .=700
  808. main:
  809.     lda.d glop
  810.     cmpa.i 55
  811.     ldx.x -5(u)
  812.     ldu.x 017(y)
  813.     ldy.x x++
  814.     blt %main
  815. .=.+11
  816.     pag2 cmpd.i =it
  817.     cwai %f(inz)
  818.     cwai 0xff
  819.     pulu %r(dxy)
  820.  
  821. .data
  822.     87
  823. SHAR_EOF
  824. if test 217 -ne "`wc -c < 'try.s'`"
  825. then
  826.     echo shar: error transmitting "'try.s'" '(should have been 217 characters)'
  827. fi
  828. fi
  829. echo shar: extracting "'try.x.good'" '(126 characters)'
  830. if test -f 'try.x.good'
  831. then
  832.     echo shar: will not over-write existing file "'try.x.good'"
  833. else
  834. cat << \SHAR_EOF > 'try.x.good'
  835. :050014000078374D5794
  836. :08004600960A8137AE7BEE2F14
  837. :04004E00AE812DF45E
  838. :08005D00108300143C1C3CFF61
  839. :0200650037362C
  840. :00000001FF
  841. SHAR_EOF
  842. if test 126 -ne "`wc -c < 'try.x.good'`"
  843. then
  844.     echo shar: error transmitting "'try.x.good'" '(should have been 126 characters)'
  845. fi
  846. fi
  847. echo shar: extracting "'01pgm.s'" '(3450 characters)'
  848. if test -f '01pgm.s'
  849. then
  850.     echo shar: will not over-write existing file "'01pgm.s'"
  851. else
  852. cat << \SHAR_EOF > '01pgm.s'
  853. #m 6801
  854. # Program to check, program, and verify a 68701.
  855. # Copied from Motorola ap note AN-832.
  856. # Timing constants assume 4Mhz crystal.
  857.  
  858. # Variables for code stolen from 68701 data sheet.
  859. .=128
  860. imbeg:    .=.+2            # Start of data block.
  861. imend:    .=.+2            # End of data block.
  862. pntr:    .=.+2            # Start of EPROM area to be done.
  863. wait:    .=.+2            # Counter value.
  864.  
  865. # Startup code.
  866. .=0xb850
  867. start:
  868.     lds.i =0xff        # Initialize stack.
  869.     ldaa.i 0x7        # Initialize port 1...
  870.     staa.d p1ddr        # ...bottom 3 bits outputs...
  871.     staa.d p1        # ...all LEDs off.
  872.  
  873. # Check if EPROM has been erased properly.
  874.     ldx.i =0xf800        # Start of EPROM.
  875.     stx.d pntr        # Initialize pntr while number is handy.
  876.     ldab.i 0        # Prepare to compare.  [Why not clrb???]
  877. erase:    ldaa.x 0        # Pick up EPROM byte.
  878.     cba
  879.     bne %error1        # Branch if not zero.
  880.     cpx.i =0xffff        # Are we done?
  881.     beq %next        # Branch on done.
  882.     inx
  883.     bra %erase
  884.  
  885. # Turn on "erased" LED.
  886. next:    ldaa.i 0x6        # First LED on.
  887.     staa.d p1
  888.  
  889. # Delay a while (3.5 s) to be sure Vpp is up.
  890.     stx.d wait        # [this seems useless]
  891.     ldx.i =70        # 70 times through loop.
  892. stall1:    dex
  893.     ldd.i =0xc350        # 50 ms loop.
  894.     addd.d timer        # Relative to current timer value.
  895.     clr.e =tcsr        # Clear output-compare bit.
  896.     std.d outcmp
  897.     ldaa.i 0x40        # Now wait for bit to come high.
  898. stall2:    bita.d tcsr
  899.     beq %stall2        # Branch on bit still 0.
  900.     cpx.i =0        # 70 times yet?  [Why not tstx???]
  901.     bne %stall1        # Branch on no.
  902.     bra %pgint        # Branch on yes.
  903.  
  904. # Light error LED only.
  905. error1:    ldaa.i 0x83        # Error LED only.  [Why not just 0x3???]
  906.     staa.d p1
  907.     bra %self
  908.  
  909. # Initialize variables for programming code.
  910. pgint:    ldx.i =0x7800        # Start of data memory.
  911.     stx.d imbeg
  912.     ldx.i =0x7fff        # End of data memory.
  913.     stx.d imend
  914.     ldx.i =0xc350        # Programming delay, 50 ms.
  915.     stx.d wait
  916.     # pntr has been initialized earlier.
  917.  
  918. # Basic programming code, from 68701 data sheet.
  919. eprom:    ldx.d pntr        # Save initial pntr on stack.
  920.     pshx
  921.     ldx.d imbeg        # x -> data
  922.  
  923. # Program a byte.
  924. epr002:    pshx            # Save data ptr on stack.
  925.     ldaa.i 0xfe        # Remove Vpp, set latch.
  926.     staa.d epromcr        # PPC=1, PLC=0.
  927.     ldaa.x 0        # Pick up data.
  928.     ldx.d pntr        # x -> dest
  929.     staa.x 0        # Store into latch.
  930.     inx            # Update destination addr...
  931.     stx.d pntr
  932.     ldaa.i 0xfc        # Fire up Vpp.
  933.     staa.d epromcr        # PPC=PLC=0.
  934.  
  935. # Wait 50 ms for programming to happen.
  936.     ldd.d wait        # d = delay.
  937.     addd.d timer        # d = time to wake up.
  938.     clr.e =tcsr        # Clear output-compare flag.
  939.     std.d outcmp        # Set alarm.
  940.     ldaa.i 0x40        # Wait for flag.
  941. epr004:    bita.d tcsr
  942.     beq %epr004        # Branch on not set yet.
  943.  
  944. # Set up for next byte.
  945.     pulx            # x -> data
  946.     inx
  947.     cpx.d imend        # Are we done?
  948.     bls %epr002        # Branch on no, with x -> next data.
  949.     ldaa.i 0xff        # Turn off Vpp, inhibit latch...
  950.     staa.d epromcr
  951.     pulx            # Put pntr back as it was...
  952.     stx.d pntr
  953.  
  954. # Verify.  End of datasheet code.
  955.     ldx.i =0x7800        # x -> data
  956. verf2:    pshx            # Save data ptr on stack.
  957.     ldaa.x 0        # a = data
  958.     ldx.d pntr        # x -> eprom
  959.     ldab.x 0        # a = eprom data
  960.     cba            # Same?
  961.     bne %error2        # Branch on different.
  962.     inx            # Next...
  963.     stx.d pntr
  964.     pulx            # x -> data
  965.     inx
  966.     cpx.i =0x8000        # Done yet?
  967.     bne %verf2        # Branch on no.
  968.  
  969. # We're done.  Light the verify LED.
  970.     ldaa.i 0x84        # Erased & verified.  [Why not just 0x4???]
  971.     staa.d p1
  972.  
  973. # Branch-to-self loop for completion and errors.
  974. self:    bra %self
  975.  
  976. # Verify error.
  977. error2:    ldaa.i 0x82        # Erased & error LEDS.  [Why not 0x2???]
  978.     staa.d p1
  979.     bra %self
  980.  
  981. # Vectors.
  982. .=0xbff0
  983.     =self
  984.     =self
  985.     =self
  986.     =self
  987.     =self
  988.     =self
  989.     =self
  990.     =start            # Reset vector.
  991. SHAR_EOF
  992. if test 3450 -ne "`wc -c < '01pgm.s'`"
  993. then
  994.     echo shar: error transmitting "'01pgm.s'" '(should have been 3450 characters)'
  995. fi
  996. fi
  997. echo shar: extracting "'01pgm.x.good'" '(670 characters)'
  998. if test -f '01pgm.x.good'
  999. then
  1000.     echo shar: will not over-write existing file "'01pgm.x.good'"
  1001. else
  1002. cat << \SHAR_EOF > '01pgm.x.good'
  1003. :08B850008E00FF8607970097A8
  1004. :08B8580002CEF800DF84C600F7
  1005. :08B86000A6001126298CFFFF50
  1006. :08B8680027030820F386069770
  1007. :08B8700002DF86CE004609CC80
  1008. :08B87800C350D3097F0008DD75
  1009. :08B880000B8640950827FC8CA3
  1010. :08B88800000026EA2006868379
  1011. :08B890009702205DCE7800DF75
  1012. :08B8980080CE7FFFDF82CEC3EA
  1013. :08B8A00050DF86DE843CDE80EF
  1014. :08B8A8003C86FE9714A600DEA9
  1015. :08B8B00084A70008DF8486FC78
  1016. :08B8B8009714DC86D3097F0020
  1017. :08B8C00008DD0B864095082706
  1018. :08B8C800FC38089C8223D9869C
  1019. :08B8D000FF971438DF84CE78E5
  1020. :08B8D800003CA600DE84E6003E
  1021. :08B8E00011261008DF8438086E
  1022. :08B8E8008C800026EC86849799
  1023. :08B8F0000220FE86829702206F
  1024. :01B8F800F857
  1025. :08BFF000B8F1B8F1B8F1B8F1A5
  1026. :08BFF800B8F1B8F1B8F1B8503E
  1027. :00000001FF
  1028. SHAR_EOF
  1029. if test 670 -ne "`wc -c < '01pgm.x.good'`"
  1030. then
  1031.     echo shar: error transmitting "'01pgm.x.good'" '(should have been 670 characters)'
  1032. fi
  1033. fi
  1034. if test ! -d '6801'
  1035. then
  1036.     echo shar: creating directory "'6801'"
  1037.     mkdir '6801'
  1038. fi
  1039. echo shar: extracting "'6801/6801.ops'" '(1340 characters)'
  1040. if test -f '6801/6801.ops'
  1041. then
  1042.     echo shar: will not over-write existing file "'6801/6801.ops'"
  1043. else
  1044. cat << \SHAR_EOF > '6801/6801.ops'
  1045.  
  1046. nop
  1047.  
  1048.  
  1049. lsrd
  1050. asld
  1051. tap
  1052. tpa
  1053. inx
  1054. dex
  1055. clv
  1056. sev
  1057. clc
  1058. sec
  1059. cli
  1060. sei
  1061. sba
  1062. cba
  1063.  
  1064.  
  1065.  
  1066.  
  1067. tab
  1068. tba
  1069.  
  1070. daa
  1071.  
  1072. aba
  1073.  
  1074.  
  1075.  
  1076.  
  1077. bra
  1078. brn
  1079. bhi
  1080. bls
  1081. bcc
  1082. bcs
  1083. bne
  1084. beq
  1085. bvc
  1086. bvs
  1087. bpl
  1088. bmi
  1089. bge
  1090. blt
  1091. bgt
  1092. ble
  1093. tsx
  1094. ins
  1095. pula
  1096. pulb
  1097. des
  1098. txs
  1099. psha
  1100. pshb
  1101. pulx
  1102. rts
  1103. abx
  1104. rti
  1105. pshx
  1106. mul
  1107. wai
  1108. swi
  1109. nega
  1110.  
  1111.  
  1112. coma
  1113. lsra
  1114.  
  1115. rora
  1116. asra
  1117. asla
  1118. rola
  1119. deca
  1120.  
  1121. inca
  1122. tsta
  1123. hcf1
  1124. clra
  1125. negb
  1126.  
  1127.  
  1128. comb
  1129. lsrb
  1130.  
  1131. rorb
  1132. asrb
  1133. aslb
  1134. rolb
  1135. decb
  1136.  
  1137. incb
  1138. tstb
  1139. hcf2
  1140. clrb
  1141. neg.x
  1142.  
  1143.  
  1144. com.x
  1145. lsr.x
  1146.  
  1147. ror.x
  1148. asr.x
  1149. asl.x
  1150. rol.x
  1151. dec.x
  1152.  
  1153. inc.x
  1154. tst.x
  1155. jmp.x
  1156. clr.x
  1157. neg.e
  1158.  
  1159.  
  1160. com.e
  1161. lsr.e
  1162.  
  1163. ror.e
  1164. asr.e
  1165. asl.e
  1166. rol.e
  1167. dec.e
  1168.  
  1169. inc.e
  1170. tst.e
  1171. jmp.e
  1172. clr.e
  1173. suba.i
  1174. cmpa.i
  1175. sbca.i
  1176. subd.i
  1177. anda.i
  1178. bita.i
  1179. ldaa.i
  1180.  
  1181. eora.i
  1182. adca.i
  1183. oraa.i
  1184. adda.i
  1185. cpx.i
  1186. bsr
  1187. lds.i
  1188.  
  1189. suba.d
  1190. cmpa.d
  1191. sbca.d
  1192. subd.d
  1193. anda.d
  1194. bita.d
  1195. ldaa.d
  1196. staa.d
  1197. eora.d
  1198. adca.d
  1199. oraa.d
  1200. adda.d
  1201. cpx.d
  1202. jsr.d
  1203. lds.d
  1204. sts.d
  1205. suba.x
  1206. cmpa.x
  1207. sbca.x
  1208. subd.x
  1209. anda.x
  1210. bita.x
  1211. ldaa.x
  1212. staa.x
  1213. eora.x
  1214. adca.x
  1215. oraa.x
  1216. adda.x
  1217. cpx.x
  1218. jsr.x
  1219. lds.x
  1220. sts.x
  1221. suba.e
  1222. cmpa.e
  1223. sbca.e
  1224. subd.e
  1225. anda.e
  1226. bita.e
  1227. ldaa.e
  1228. staa.e
  1229. eora.e
  1230. adca.e
  1231. oraa.e
  1232. adda.e
  1233. cpx.e
  1234. jsr.e
  1235. lds.e
  1236. sts.e
  1237. subb.i
  1238. cmpb.i
  1239. sbcb.i
  1240. addd.i
  1241. andb.i
  1242. bitb.i
  1243. ldab.i
  1244.  
  1245. eorb.i
  1246. adcb.i
  1247. orab.i
  1248. addb.i
  1249. ldd.i
  1250.  
  1251. ldx.i
  1252.  
  1253. subb.d
  1254. cmpb.d
  1255. sbcb.d
  1256. addd.d
  1257. andb.d
  1258. bitb.d
  1259. ldab.d
  1260. stab.d
  1261. eorb.d
  1262. adcb.d
  1263. orab.d
  1264. addb.d
  1265. ldd.d
  1266. std.d
  1267. ldx.d
  1268. stx.d
  1269. subb.x
  1270. cmpb.x
  1271. sbcb.x
  1272. addd.x
  1273. andb.x
  1274. bitb.x
  1275. ldab.x
  1276. stab.x
  1277. eorb.x
  1278. adcb.x
  1279. orab.x
  1280. addb.x
  1281. ldd.x
  1282. std.x
  1283. ldx.x
  1284. stx.x
  1285. subb.e
  1286. cmpb.e
  1287. sbcb.e
  1288. addd.e
  1289. andb.e
  1290. bitb.e
  1291. ldab.e
  1292. stab.e
  1293. eorb.e
  1294. adcb.e
  1295. orab.e
  1296. addb.e
  1297. ldd.e
  1298. std.e
  1299. ldx.e
  1300. stx.e
  1301. SHAR_EOF
  1302. if test 1340 -ne "`wc -c < '6801/6801.ops'`"
  1303. then
  1304.     echo shar: error transmitting "'6801/6801.ops'" '(should have been 1340 characters)'
  1305. fi
  1306. fi
  1307. echo shar: extracting "'6801/6801.regs'" '(179 characters)'
  1308. if test -f '6801/6801.regs'
  1309. then
  1310.     echo shar: will not over-write existing file "'6801/6801.regs'"
  1311. else
  1312. cat << \SHAR_EOF > '6801/6801.regs'
  1313. p1ddr
  1314. p2ddr
  1315. p1
  1316. p2
  1317. p3ddr
  1318. p4ddr
  1319. p3
  1320. p4
  1321. tcsr
  1322. th timer
  1323. tl
  1324. ocrh outcmp
  1325. ocrl
  1326. icrh
  1327. icrl
  1328. p3csr
  1329. rmcr
  1330. trcsr
  1331. rd
  1332. td
  1333. ramcr epromcr mcr
  1334. cah
  1335. cal
  1336. tcr1
  1337. tcr2
  1338. tsr
  1339. ocr2h
  1340. ocr2l
  1341. ocr3h
  1342. ocr3l
  1343. icr2h
  1344. icr2l
  1345. SHAR_EOF
  1346. if test 179 -ne "`wc -c < '6801/6801.regs'`"
  1347. then
  1348.     echo shar: error transmitting "'6801/6801.regs'" '(should have been 179 characters)'
  1349. fi
  1350. fi
  1351. echo shar: extracting "'6801/card'" '(558 characters)'
  1352. if test -f '6801/card'
  1353. then
  1354.     echo shar: will not over-write existing file "'6801/card'"
  1355. else
  1356. cat << \SHAR_EOF > '6801/card'
  1357. #m 6801    what machine this is for (first line only)
  1358. #foo    comment
  1359. x;y    two successive bytes
  1360. x y    two successive bytes
  1361. 07    octal
  1362. 0x7    hex
  1363. 'c    character constant
  1364. '\n    ditto
  1365. foo:    label
  1366. x=100    definition (numbers only)
  1367. .=100    setting location counter (numbers only)
  1368. .=.+5    bumping location counter (numbers only)
  1369. .text    what it says
  1370. .data    ditto
  1371. .bss    ditto
  1372. =thing    two-byte constant
  1373. /thing    lower byte of 16-bit thing
  1374. \thing    upper byte of 16-bit thing
  1375. %thing    lower byte of 16-bit thing as an offset relative to PC
  1376. %%thing    upper byte of 16-bit thing as an offset relative to PC
  1377. SHAR_EOF
  1378. if test 558 -ne "`wc -c < '6801/card'`"
  1379. then
  1380.     echo shar: error transmitting "'6801/card'" '(should have been 558 characters)'
  1381. fi
  1382. fi
  1383. echo shar: extracting "'6801/final'" '(1299 characters)'
  1384. if test -f '6801/final'
  1385. then
  1386.     echo shar: will not over-write existing file "'6801/final'"
  1387. else
  1388. cat << \SHAR_EOF > '6801/final'
  1389. # Final postprocessing, to handle high/low byte-extraction operators,
  1390. # and compute PC-relative offsets.  The only thing that is really
  1391. # machine-dependent here is the pcbias's, which reflect the difference
  1392. # between the location of an offset byte and the PC which should be
  1393. # used in computing it (i.e., how far ahead the PC is by the time the
  1394. # byte is used to alter the PC).
  1395. BEGIN {
  1396.     FS = "\t"
  1397.     OFS = "\t"
  1398.     pcbiaslo = 1
  1399.     pcbiashi = 2
  1400.     if (pcbiaslo > pcbiashi)
  1401.         pcbiasmax = pcbiaslo
  1402.     else
  1403.         pcbiasmax = pcbiashi
  1404. }
  1405. {
  1406.     if ($2 == "") {            # Number or something, not symbol.
  1407.         if ($3 ~ /^\/[0-9]/) {
  1408.             it = substr($3, 2);
  1409.             while (it < 0)
  1410.                 it += 65536
  1411.             print $1, int(it%256 + 0.001), "# " $3
  1412.         } else if ($3 ~ /^\\[0-9]/) {
  1413.             it = substr($3, 2);
  1414.             while (it < 0)
  1415.                 it += 65536
  1416.             print $1, int(it/256 + 0.001), "# " $3
  1417.         } else
  1418.             print $1, $3
  1419.     } else if ($2 ~ /^[0-9]+$/)    # Symbol, ordinary value.
  1420.         print $1, $2, "# " $3
  1421.     else if ($2 ~ /%$/) {        # Symbol, PC-relative value.
  1422.         base = substr($1, 1, length($1)-1)
  1423.         it = substr($2, 2, length($2)-2)
  1424.         p = it - base
  1425.         while (p < pcbiasmax)
  1426.             p += 65536
  1427.         if ($2 ~ /^\//)
  1428.             print $1, int((p - pcbiaslo)%256 + 0.001), "# " $3
  1429.         else
  1430.             print $1, int((p - pcbiashi)/256 + 0.001), "# " $3
  1431.     } else                # Something else.
  1432.         print $1, $2, "# " $3
  1433. }
  1434. SHAR_EOF
  1435. if test 1299 -ne "`wc -c < '6801/final'`"
  1436. then
  1437.     echo shar: error transmitting "'6801/final'" '(should have been 1299 characters)'
  1438. fi
  1439. fi
  1440. echo shar: extracting "'6801/notn'" '(346 characters)'
  1441. if test -f '6801/notn'
  1442. then
  1443.     echo shar: will not over-write existing file "'6801/notn'"
  1444. else
  1445. cat << \SHAR_EOF > '6801/notn'
  1446. # Main preprocessing, handling 6801-specific notation (actually none) as
  1447. # well as some more-or-less machine-independent odds and ends (two-byte
  1448. # constants (note byte order known)).
  1449. /^=/ {                # Two-byte constant, in proper byte order.
  1450.     print "\\" substr($0, 2)
  1451.     print "/" substr($0, 2)
  1452.     next
  1453. }
  1454. /./ { print }            # Something else, leave untouched.
  1455. SHAR_EOF
  1456. if test 346 -ne "`wc -c < '6801/notn'`"
  1457. then
  1458.     echo shar: error transmitting "'6801/notn'" '(should have been 346 characters)'
  1459. fi
  1460. fi
  1461. echo shar: extracting "'6801/opgen'" '(134 characters)'
  1462. if test -f '6801/opgen'
  1463. then
  1464.     echo shar: will not over-write existing file "'6801/opgen'"
  1465. else
  1466. cat << \SHAR_EOF > '6801/opgen'
  1467. # Tool for building 6801 opcode list.
  1468. BEGIN { opno = 0 }
  1469. {
  1470.     if ($0 != "")
  1471.         for (i = 1; i <= NF; i++)
  1472.             print $i "\t" opno
  1473.     opno++
  1474. }
  1475. SHAR_EOF
  1476. if test 134 -ne "`wc -c < '6801/opgen'`"
  1477. then
  1478.     echo shar: error transmitting "'6801/opgen'" '(should have been 134 characters)'
  1479. fi
  1480. fi
  1481. echo shar: extracting "'6801/predef'" '(2985 characters)'
  1482. if test -f '6801/predef'
  1483. then
  1484.     echo shar: will not over-write existing file "'6801/predef'"
  1485. else
  1486. cat << \SHAR_EOF > '6801/predef'
  1487. nop    1
  1488. lsrd    4
  1489. asld    5
  1490. tap    6
  1491. tpa    7
  1492. inx    8
  1493. dex    9
  1494. clv    10
  1495. sev    11
  1496. clc    12
  1497. sec    13
  1498. cli    14
  1499. sei    15
  1500. sba    16
  1501. cba    17
  1502. tab    22
  1503. tba    23
  1504. daa    25
  1505. aba    27
  1506. bra    32
  1507. brn    33
  1508. bhi    34
  1509. bls    35
  1510. bcc    36
  1511. bcs    37
  1512. bne    38
  1513. beq    39
  1514. bvc    40
  1515. bvs    41
  1516. bpl    42
  1517. bmi    43
  1518. bge    44
  1519. blt    45
  1520. bgt    46
  1521. ble    47
  1522. tsx    48
  1523. ins    49
  1524. pula    50
  1525. pulb    51
  1526. des    52
  1527. txs    53
  1528. psha    54
  1529. pshb    55
  1530. pulx    56
  1531. rts    57
  1532. abx    58
  1533. rti    59
  1534. pshx    60
  1535. mul    61
  1536. wai    62
  1537. swi    63
  1538. nega    64
  1539. coma    67
  1540. lsra    68
  1541. rora    70
  1542. asra    71
  1543. asla    72
  1544. rola    73
  1545. deca    74
  1546. inca    76
  1547. tsta    77
  1548. hcf1    78
  1549. clra    79
  1550. negb    80
  1551. comb    83
  1552. lsrb    84
  1553. rorb    86
  1554. asrb    87
  1555. aslb    88
  1556. rolb    89
  1557. decb    90
  1558. incb    92
  1559. tstb    93
  1560. hcf2    94
  1561. clrb    95
  1562. neg.x    96
  1563. com.x    99
  1564. lsr.x    100
  1565. ror.x    102
  1566. asr.x    103
  1567. asl.x    104
  1568. rol.x    105
  1569. dec.x    106
  1570. inc.x    108
  1571. tst.x    109
  1572. jmp.x    110
  1573. clr.x    111
  1574. neg.e    112
  1575. com.e    115
  1576. lsr.e    116
  1577. ror.e    118
  1578. asr.e    119
  1579. asl.e    120
  1580. rol.e    121
  1581. dec.e    122
  1582. inc.e    124
  1583. tst.e    125
  1584. jmp.e    126
  1585. clr.e    127
  1586. suba.i    128
  1587. cmpa.i    129
  1588. sbca.i    130
  1589. subd.i    131
  1590. anda.i    132
  1591. bita.i    133
  1592. ldaa.i    134
  1593. eora.i    136
  1594. adca.i    137
  1595. oraa.i    138
  1596. adda.i    139
  1597. cpx.i    140
  1598. bsr    141
  1599. lds.i    142
  1600. suba.d    144
  1601. cmpa.d    145
  1602. sbca.d    146
  1603. subd.d    147
  1604. anda.d    148
  1605. bita.d    149
  1606. ldaa.d    150
  1607. staa.d    151
  1608. eora.d    152
  1609. adca.d    153
  1610. oraa.d    154
  1611. adda.d    155
  1612. cpx.d    156
  1613. jsr.d    157
  1614. lds.d    158
  1615. sts.d    159
  1616. suba.x    160
  1617. cmpa.x    161
  1618. sbca.x    162
  1619. subd.x    163
  1620. anda.x    164
  1621. bita.x    165
  1622. ldaa.x    166
  1623. staa.x    167
  1624. eora.x    168
  1625. adca.x    169
  1626. oraa.x    170
  1627. adda.x    171
  1628. cpx.x    172
  1629. jsr.x    173
  1630. lds.x    174
  1631. sts.x    175
  1632. suba.e    176
  1633. cmpa.e    177
  1634. sbca.e    178
  1635. subd.e    179
  1636. anda.e    180
  1637. bita.e    181
  1638. ldaa.e    182
  1639. staa.e    183
  1640. eora.e    184
  1641. adca.e    185
  1642. oraa.e    186
  1643. adda.e    187
  1644. cpx.e    188
  1645. jsr.e    189
  1646. lds.e    190
  1647. sts.e    191
  1648. subb.i    192
  1649. cmpb.i    193
  1650. sbcb.i    194
  1651. addd.i    195
  1652. andb.i    196
  1653. bitb.i    197
  1654. ldab.i    198
  1655. eorb.i    200
  1656. adcb.i    201
  1657. orab.i    202
  1658. addb.i    203
  1659. ldd.i    204
  1660. ldx.i    206
  1661. subb.d    208
  1662. cmpb.d    209
  1663. sbcb.d    210
  1664. addd.d    211
  1665. andb.d    212
  1666. bitb.d    213
  1667. ldab.d    214
  1668. stab.d    215
  1669. eorb.d    216
  1670. adcb.d    217
  1671. orab.d    218
  1672. addb.d    219
  1673. ldd.d    220
  1674. std.d    221
  1675. ldx.d    222
  1676. stx.d    223
  1677. subb.x    224
  1678. cmpb.x    225
  1679. sbcb.x    226
  1680. addd.x    227
  1681. andb.x    228
  1682. bitb.x    229
  1683. ldab.x    230
  1684. stab.x    231
  1685. eorb.x    232
  1686. adcb.x    233
  1687. orab.x    234
  1688. addb.x    235
  1689. ldd.x    236
  1690. std.x    237
  1691. ldx.x    238
  1692. stx.x    239
  1693. subb.e    240
  1694. cmpb.e    241
  1695. sbcb.e    242
  1696. addd.e    243
  1697. andb.e    244
  1698. bitb.e    245
  1699. ldab.e    246
  1700. stab.e    247
  1701. eorb.e    248
  1702. adcb.e    249
  1703. orab.e    250
  1704. addb.e    251
  1705. ldd.e    252
  1706. std.e    253
  1707. ldx.e    254
  1708. stx.e    255
  1709. p1ddr    0
  1710. /p1ddr    0
  1711. \p1ddr    0
  1712. p2ddr    1
  1713. /p2ddr    1
  1714. \p2ddr    0
  1715. p1    2
  1716. /p1    2
  1717. \p1    0
  1718. p2    3
  1719. /p2    3
  1720. \p2    0
  1721. p3ddr    4
  1722. /p3ddr    4
  1723. \p3ddr    0
  1724. p4ddr    5
  1725. /p4ddr    5
  1726. \p4ddr    0
  1727. p3    6
  1728. /p3    6
  1729. \p3    0
  1730. p4    7
  1731. /p4    7
  1732. \p4    0
  1733. tcsr    8
  1734. /tcsr    8
  1735. \tcsr    0
  1736. th    9
  1737. /th    9
  1738. \th    0
  1739. timer    9
  1740. /timer    9
  1741. \timer    0
  1742. tl    10
  1743. /tl    10
  1744. \tl    0
  1745. ocrh    11
  1746. /ocrh    11
  1747. \ocrh    0
  1748. outcmp    11
  1749. /outcmp    11
  1750. \outcmp    0
  1751. ocrl    12
  1752. /ocrl    12
  1753. \ocrl    0
  1754. icrh    13
  1755. /icrh    13
  1756. \icrh    0
  1757. icrl    14
  1758. /icrl    14
  1759. \icrl    0
  1760. p3csr    15
  1761. /p3csr    15
  1762. \p3csr    0
  1763. rmcr    16
  1764. /rmcr    16
  1765. \rmcr    0
  1766. trcsr    17
  1767. /trcsr    17
  1768. \trcsr    0
  1769. rd    18
  1770. /rd    18
  1771. \rd    0
  1772. td    19
  1773. /td    19
  1774. \td    0
  1775. ramcr    20
  1776. /ramcr    20
  1777. \ramcr    0
  1778. epromcr    20
  1779. /epromcr    20
  1780. \epromcr    0
  1781. mcr    20
  1782. /mcr    20
  1783. \mcr    0
  1784. cah    21
  1785. /cah    21
  1786. \cah    0
  1787. cal    22
  1788. /cal    22
  1789. \cal    0
  1790. tcr1    23
  1791. /tcr1    23
  1792. \tcr1    0
  1793. tcr2    24
  1794. /tcr2    24
  1795. \tcr2    0
  1796. tsr    25
  1797. /tsr    25
  1798. \tsr    0
  1799. ocr2h    26
  1800. /ocr2h    26
  1801. \ocr2h    0
  1802. ocr2l    27
  1803. /ocr2l    27
  1804. \ocr2l    0
  1805. ocr3h    28
  1806. /ocr3h    28
  1807. \ocr3h    0
  1808. ocr3l    29
  1809. /ocr3l    29
  1810. \ocr3l    0
  1811. icr2h    30
  1812. /icr2h    30
  1813. \icr2h    0
  1814. icr2l    31
  1815. /icr2l    31
  1816. \icr2l    0
  1817. SHAR_EOF
  1818. if test 2985 -ne "`wc -c < '6801/predef'`"
  1819. then
  1820.     echo shar: error transmitting "'6801/predef'" '(should have been 2985 characters)'
  1821. fi
  1822. fi
  1823. echo shar: extracting "'6801/reggen'" '(208 characters)'
  1824. if test -f '6801/reggen'
  1825. then
  1826.     echo shar: will not over-write existing file "'6801/reggen'"
  1827. else
  1828. cat << \SHAR_EOF > '6801/reggen'
  1829. # Program to generate register definitions for 6801.
  1830. BEGIN { regno = 0 }
  1831. {
  1832.     if ($0 != "")
  1833.         for (i = 1; i <= NF; i++) {
  1834.             print $i "\t" regno
  1835.             print "/" $i "\t" regno
  1836.             print "\\" $i "\t0"
  1837.         }
  1838.     regno++
  1839. }
  1840. SHAR_EOF
  1841. if test 208 -ne "`wc -c < '6801/reggen'`"
  1842. then
  1843.     echo shar: error transmitting "'6801/reggen'" '(should have been 208 characters)'
  1844. fi
  1845. fi
  1846. echo shar: extracting "'6801/Makefile'" '(88 characters)'
  1847. if test -f '6801/Makefile'
  1848. then
  1849.     echo shar: will not over-write existing file "'6801/Makefile'"
  1850. else
  1851. cat << \SHAR_EOF > '6801/Makefile'
  1852. predef:    6801.ops 6801.regs
  1853.     ( awk -f opgen 6801.ops ; awk -f reggen 6801.regs ) >predef
  1854. SHAR_EOF
  1855. if test 88 -ne "`wc -c < '6801/Makefile'`"
  1856. then
  1857.     echo shar: error transmitting "'6801/Makefile'" '(should have been 88 characters)'
  1858. fi
  1859. fi
  1860. echo shar: done with directory "'6801'"
  1861. if test ! -d '6809'
  1862. then
  1863.     echo shar: creating directory "'6809'"
  1864.     mkdir '6809'
  1865. fi
  1866. echo shar: extracting "'6809/6809.ops'" '(1408 characters)'
  1867. if test -f '6809/6809.ops'
  1868. then
  1869.     echo shar: will not over-write existing file "'6809/6809.ops'"
  1870. else
  1871. cat << \SHAR_EOF > '6809/6809.ops'
  1872. neg.d
  1873.  
  1874.  
  1875. com.d
  1876. lsr.d
  1877.  
  1878. ror.d
  1879. asr.d
  1880. asl.d lsl.d
  1881. rol.d
  1882. dec.d
  1883.  
  1884. inc.d
  1885. tst.d
  1886. jmp.d
  1887. clr.d
  1888. pag2
  1889. pag3
  1890. nop
  1891. sync
  1892.  
  1893.  
  1894. lbra.r
  1895. lbsr.r
  1896.  
  1897. daa
  1898. orcc.i
  1899.  
  1900. andcc.i
  1901. sex
  1902. exg
  1903. tfr
  1904. bra
  1905. brn
  1906. bhi
  1907. bls
  1908. bhs bcc
  1909. blo bcs
  1910. bne
  1911. beq
  1912. bvc
  1913. bvs
  1914. bpl
  1915. bmi
  1916. bge
  1917. blt
  1918. bgt
  1919. ble
  1920. leax.x
  1921. leay.x
  1922. leas.x
  1923. leau.x
  1924. pshs
  1925. puls
  1926. pshu
  1927. pulu
  1928.  
  1929. rts
  1930. abx
  1931. rti
  1932. cwai
  1933. mul
  1934.  
  1935. swi
  1936. nega
  1937.  
  1938.  
  1939. coma
  1940. lsra
  1941.  
  1942. rora
  1943. asra
  1944. asla lsla
  1945. rola
  1946. deca
  1947.  
  1948. inca
  1949. tsta
  1950.  
  1951. clra
  1952. negb
  1953.  
  1954.  
  1955. comb
  1956. lsrb
  1957.  
  1958. rorb
  1959. asrb
  1960. aslb lslb
  1961. rolb
  1962. decb
  1963.  
  1964. incb
  1965. tstb
  1966.  
  1967. clrb
  1968. neg.x
  1969.  
  1970.  
  1971. com.x
  1972. lsr.x
  1973.  
  1974. ror.x
  1975. asr.x
  1976. asl.x lsl.x
  1977. rol.x
  1978. dec.x
  1979.  
  1980. inc.x
  1981. tst.x
  1982. jmp.x
  1983. clr.x
  1984. neg.e
  1985.  
  1986.  
  1987. com.e
  1988. lsr.e
  1989.  
  1990. ror.e
  1991. asr.e
  1992. asl.e lsl.e
  1993. rol.e
  1994. dec.e
  1995.  
  1996. inc.e
  1997. tst.e
  1998. jmp.e
  1999. clr.e
  2000. suba.i
  2001. cmpa.i
  2002. sbca.i
  2003. subd.i
  2004. anda.i
  2005. bita.i
  2006. lda.i
  2007.  
  2008. eora.i
  2009. adca.i
  2010. ora.i
  2011. adda.i
  2012. cmpx.i
  2013. bsr
  2014. ldx.i
  2015.  
  2016. suba.d
  2017. cmpa.d
  2018. sbca.d
  2019. subd.d
  2020. anda.d
  2021. bita.d
  2022. lda.d
  2023. sta.d
  2024. eora.d
  2025. adca.d
  2026. ora.d
  2027. adda.d
  2028. cmpx.d
  2029. jsr.d
  2030. ldx.d
  2031. stx.d
  2032. suba.x
  2033. cmpa.x
  2034. sbca.x
  2035. subd.x
  2036. anda.x
  2037. bita.x
  2038. lda.x
  2039. sta.x
  2040. eora.x
  2041. adca.x
  2042. ora.x
  2043. adda.x
  2044. cmpx.x
  2045. jsr.x
  2046. ldx.x
  2047. stx.x
  2048. suba.e
  2049. cmpa.e
  2050. sbca.e
  2051. subd.e
  2052. anda.e
  2053. bita.e
  2054. lda.e
  2055. sta.e
  2056. eora.e
  2057. adca.e
  2058. ora.e
  2059. adda.e
  2060. cmpx.e
  2061. jsr.e
  2062. ldx.e
  2063. stx.e
  2064. subb.i
  2065. cmpb.i
  2066. sbcb.i
  2067. addd.i
  2068. andb.i
  2069. bitb.i
  2070. ldb.i
  2071.  
  2072. eorb.i
  2073. adcb.i
  2074. orb.i
  2075. addb.i
  2076. ldd.i
  2077.  
  2078. ldu.i
  2079.  
  2080. subb.d
  2081. cmpb.d
  2082. sbcb.d
  2083. addd.d
  2084. andb.d
  2085. bitb.d
  2086. ldb.d
  2087. stb.d
  2088. eorb.d
  2089. adcb.d
  2090. orb.d
  2091. addb.d
  2092. ldd.d
  2093. std.d
  2094. ldu.d
  2095. stu.d
  2096. subb.x
  2097. cmpb.x
  2098. sbcb.x
  2099. addd.x
  2100. andb.x
  2101. bitb.x
  2102. ldb.x
  2103. stb.x
  2104. eorb.x
  2105. adcb.x
  2106. orb.x
  2107. addb.x
  2108. ldd.x
  2109. std.x
  2110. ldu.x
  2111. stu.x
  2112. subb.e
  2113. cmpb.e
  2114. sbcb.e
  2115. addd.e
  2116. andb.e
  2117. bitb.e
  2118. ldb.e
  2119. stb.e
  2120. eorb.e
  2121. adcb.e
  2122. orb.e
  2123. addb.e
  2124. ldd.e
  2125. std.e
  2126. ldu.e
  2127. stu.e
  2128. SHAR_EOF
  2129. if test 1408 -ne "`wc -c < '6809/6809.ops'`"
  2130. then
  2131.     echo shar: error transmitting "'6809/6809.ops'" '(should have been 1408 characters)'
  2132. fi
  2133. fi
  2134. echo shar: extracting "'6809/6809.opsup'" '(468 characters)'
  2135. if test -f '6809/6809.opsup'
  2136. then
  2137.     echo shar: will not over-write existing file "'6809/6809.opsup'"
  2138. else
  2139. cat << \SHAR_EOF > '6809/6809.opsup'
  2140. lbrn    33
  2141. lbhi    34
  2142. lbls    35
  2143. lbhs    36
  2144. lbcc    36
  2145. lbcs    37
  2146. lblo    37
  2147. lbne    38
  2148. lbeq    39
  2149. lbvc    40
  2150. lbvs    41
  2151. lbpl    42
  2152. lbmi    43
  2153. lbge    44
  2154. lblt    45
  2155. lbgt    46
  2156. lble    47
  2157. swi2    63
  2158. cmpd.i    131
  2159. cmpy.i    140
  2160. ldy.i    142
  2161. cmpd.d    147
  2162. cmpy.d    156
  2163. ldy.d    158
  2164. sty.d    159
  2165. cmpd.x    163
  2166. cmpy.x    172
  2167. ldy.x    174
  2168. sty.x    175
  2169. cmpd.e    179
  2170. cmpy.e    188
  2171. ldy.e    190
  2172. sty.e    191
  2173. lds.i    206
  2174. lds.d    222
  2175. sts.d    223
  2176. lds.x    238
  2177. sts.x    239
  2178. lds.e    254
  2179. sts.e    255
  2180. swi3    63
  2181. cmpu.i    131
  2182. cmps.i    140
  2183. cmpu.d    147
  2184. cmps.d    156
  2185. cmpu.x    163
  2186. cmps.x    172
  2187. cmpu.e    179
  2188. cmps.e    188
  2189. SHAR_EOF
  2190. if test 468 -ne "`wc -c < '6809/6809.opsup'`"
  2191. then
  2192.     echo shar: error transmitting "'6809/6809.opsup'" '(should have been 468 characters)'
  2193. fi
  2194. fi
  2195. echo shar: extracting "'6809/card'" '(1367 characters)'
  2196. if test -f '6809/card'
  2197. then
  2198.     echo shar: will not over-write existing file "'6809/card'"
  2199. else
  2200. cat << \SHAR_EOF > '6809/card'
  2201. #m 6809    what machine this is for (first line only)
  2202. #foo    comment
  2203. x;y    two successive bytes
  2204. x y    two successive bytes
  2205. 07    octal
  2206. 0x7    hex
  2207. 'c    character constant
  2208. '\n    ditto
  2209. foo:    label
  2210. x=100    definition (numbers only)
  2211. .=100    setting location counter (numbers only)
  2212. .=.+5    bumping location counter (numbers only)
  2213. .text    what it says
  2214. .data    ditto
  2215. .bss    ditto
  2216. =thing    two-byte constant
  2217. /thing    lower byte of 16-bit thing
  2218. \thing    upper byte of 16-bit thing
  2219. %thing    lower byte of 16-bit thing as an offset relative to PC
  2220. %%thing    upper byte of 16-bit thing as an offset relative to PC
  2221. %f(xyz)    condition-code flags literal (all = *)
  2222. %r(xyz)    register mask for psh/pul (pc = p, dpr = z, ccr = c, all of them = *)
  2223. x->y    register pair for tfr
  2224. x<-y    register pair for tfr
  2225. x<->y    register pair for exg
  2226. 15(x)    index postbyte, 5-bit offset (cannot be a defined symbol, sorry)
  2227. _(x)    index postbyte, 8-bit offset follows
  2228. @_(x)    index postbyte, 8-bit offset follows, indirect
  2229. __(x)    index postbyte, 16-bit offset follows
  2230. (x)    index postbyte, register indirect
  2231. -y    index postbyte, register autodecrement
  2232. --y    index postbyte, register autodecrement by 2
  2233. y+    index postbyte, register autoincrement
  2234. y++    index postbyte, register autoincrement by 2
  2235. a(y)    index postbyte, offset in A
  2236. _(.)    index postbyte, 8-bit offset from PC follows
  2237. __(.)    index postbyte, 16-bit offset from PC follows
  2238. (__)    index postbyte, indirect extended
  2239. SHAR_EOF
  2240. if test 1367 -ne "`wc -c < '6809/card'`"
  2241. then
  2242.     echo shar: error transmitting "'6809/card'" '(should have been 1367 characters)'
  2243. fi
  2244. fi
  2245. echo shar: extracting "'6809/final'" '(1299 characters)'
  2246. if test -f '6809/final'
  2247. then
  2248.     echo shar: will not over-write existing file "'6809/final'"
  2249. else
  2250. cat << \SHAR_EOF > '6809/final'
  2251. # Final postprocessing, to handle high/low byte-extraction operators,
  2252. # and compute PC-relative offsets.  The only thing that is really
  2253. # machine-dependent here is the pcbias's, which reflect the difference
  2254. # between the location of an offset byte and the PC which should be
  2255. # used in computing it (i.e., how far ahead the PC is by the time the
  2256. # byte is used to alter the PC).
  2257. BEGIN {
  2258.     FS = "\t"
  2259.     OFS = "\t"
  2260.     pcbiaslo = 1
  2261.     pcbiashi = 2
  2262.     if (pcbiaslo > pcbiashi)
  2263.         pcbiasmax = pcbiaslo
  2264.     else
  2265.         pcbiasmax = pcbiashi
  2266. }
  2267. {
  2268.     if ($2 == "") {            # Number or something, not symbol.
  2269.         if ($3 ~ /^\/[0-9]/) {
  2270.             it = substr($3, 2);
  2271.             while (it < 0)
  2272.                 it += 65536
  2273.             print $1, int(it%256 + 0.001), "# " $3
  2274.         } else if ($3 ~ /^\\[0-9]/) {
  2275.             it = substr($3, 2);
  2276.             while (it < 0)
  2277.                 it += 65536
  2278.             print $1, int(it/256 + 0.001), "# " $3
  2279.         } else
  2280.             print $1, $3
  2281.     } else if ($2 ~ /^[0-9]+$/)    # Symbol, ordinary value.
  2282.         print $1, $2, "# " $3
  2283.     else if ($2 ~ /%$/) {        # Symbol, PC-relative value.
  2284.         base = substr($1, 1, length($1)-1)
  2285.         it = substr($2, 2, length($2)-2)
  2286.         p = it - base
  2287.         while (p < pcbiasmax)
  2288.             p += 65536
  2289.         if ($2 ~ /^\//)
  2290.             print $1, int((p - pcbiaslo)%256 + 0.001), "# " $3
  2291.         else
  2292.             print $1, int((p - pcbiashi)/256 + 0.001), "# " $3
  2293.     } else                # Something else.
  2294.         print $1, $2, "# " $3
  2295. }
  2296. SHAR_EOF
  2297. if test 1299 -ne "`wc -c < '6809/final'`"
  2298. then
  2299.     echo shar: error transmitting "'6809/final'" '(should have been 1299 characters)'
  2300. fi
  2301. fi
  2302. echo shar: extracting "'6809/notn'" '(3227 characters)'
  2303. if test -f '6809/notn'
  2304. then
  2305.     echo shar: will not over-write existing file "'6809/notn'"
  2306. else
  2307. cat << \SHAR_EOF > '6809/notn'
  2308. # Main preprocessing, handling 6809-specific notation (mostly postbytes,
  2309. # notably indexed-mode addressing formulations but also things like register
  2310. # masks) as well as some more-or-less machine-independent odds and ends
  2311. # (two-byte constants (note byte order known)).
  2312. BEGIN {
  2313.     # Bit names for condition-code postbyte.
  2314.     flags["e"] = 128
  2315.     flags["f"] = 64
  2316.     flags["h"] = 32
  2317.     flags["i"] = 16
  2318.     flags["n"] = 8
  2319.     flags["z"] = 4
  2320.     flags["v"] = 2
  2321.     flags["c"] = 1
  2322.     flags["*"] = 255
  2323.     # Bit names for register-mask postbyte.
  2324.     regs["p"] = 128            # pc
  2325.     regs["s"] = 64
  2326.     regs["u"] = 64
  2327.     regs["y"] = 32
  2328.     regs["x"] = 16
  2329.     regs["z"] = 8            # dp
  2330.     regs["b"] = 4
  2331.     regs["a"] = 2
  2332.     regs["c"] = 1            # cc
  2333.     regs["d"] = 4+2
  2334.     regs["*"] = 255
  2335.     # Register numbers for tfr/exg postbyte.
  2336.     tfrexg["d"] = 0
  2337.     tfrexg["x"] = 1
  2338.     tfrexg["y"] = 2
  2339.     tfrexg["u"] = 3
  2340.     tfrexg["s"] = 4
  2341.     tfrexg["p"] = 5
  2342.     tfrexg["a"] = 8
  2343.     tfrexg["b"] = 9
  2344.     tfrexg["c"] = 10
  2345.     tfrexg["z"] = 11
  2346.     # Register codes for index postbyte.
  2347.     ireg["x"] = 0
  2348.     ireg["y"] = 32
  2349.     ireg["u"] = 64
  2350.     ireg["s"] = 96
  2351.     # Postbyte codes for offset indexed addressing modes.
  2352.     ioff["a"] = 128 + 6
  2353.     ioff["b"] = 128 + 5
  2354.     ioff["d"] = 128 + 11
  2355.     ioff["_"] = 128 + 8        # 8-bit offset follows.
  2356. }
  2357. /^%f\(.*\)$/ {            # Flags postbyte.
  2358.     total = 0
  2359.     for (i = length-1; i > 2; i--)
  2360.         total += flags[substr($0, i, 1)]
  2361.     print total
  2362.     next
  2363. }
  2364. /^%r\(.*\)$/ {            # Register-mask postbyte.
  2365.     total = 0
  2366.     for (i = length-1; i > 2; i--)
  2367.         total += regs[substr($0, i, 1)]
  2368.     print total
  2369.     next
  2370. }
  2371. /^.->.$/ {            # Tfr postbyte.
  2372.     print tfrexg[substr($0, 1, 1)]*16 + tfrexg[substr($0, 4, 1)]
  2373.     next
  2374. }
  2375. /^.<-.$/ {            # Tfr postbyte, alternate form.
  2376.     print tfrexg[substr($0, 1, 1)] + tfrexg[substr($0, 4, 1)]*16
  2377.     next
  2378. }
  2379. /^.<->.$/ {            # Exg postbyte.
  2380.     print tfrexg[substr($0, 1, 1)]*16 + tfrexg[substr($0, 5, 1)]
  2381.     next
  2382. }
  2383. /^-?[1-9][0-9]*\([xyus]\)$/ {    # Index postbyte, 5-bit offset.
  2384.     offset = substr($0, 1, length-3)
  2385.     if (offset < 0)
  2386.         offset += 64
  2387.     print offset + ireg[substr($0, length-1, 1)]
  2388.     next
  2389. }
  2390. /^@/ { i = 16 }            # Indirect modifier for rest of index modes.
  2391. /^[^@]/ { i = 0 }        # No indirect modifier.
  2392. /^-[xyus]$/ {            # Autodecrement by 1, no indirection allowed.
  2393.     print 128 + 2 + ireg[substr($0, length, 1)]
  2394.     next
  2395. }
  2396. /^@?--[xyus]$/ {        # Autodecrement by 2.
  2397.     print 128 + 3 + ireg[substr($0, length, 1)] + i
  2398.     next
  2399. }
  2400. /^[xyus]\+$/ {            # Autoincrement by 1, no indirection allowed.
  2401.     print 128 + ireg[substr($0, 0, 1)]
  2402.     next
  2403. }
  2404. /^@?[xyus]\+\+$/ {        # Autoincrement by 2.
  2405.     print 128 + 1 + ireg[substr($0, length-2, 1)] + i
  2406.     next
  2407. }
  2408. /^@?\([xyus]\)$/ {        # Address in register, no offset.
  2409.     print 128 + 4 + ireg[substr($0, length-1, 1)] + i
  2410.     next
  2411. }
  2412. /^@?[abd_]\([xyus]\)$/ {    # Register offset or 8-bit offset.
  2413.     print ioff[substr($0, length-3, 1)] + ireg[substr($0, length-1, 1)] + i
  2414.     next
  2415. }
  2416. /^@?__\([xyus]\)$/ {        # 16-bit offset.
  2417.     print 128 + 9 + ireg[substr($0, length-1, 1)] + i
  2418.     next
  2419. }
  2420. /^\(__\)$/ {            # Indirect extended, no further indirection.
  2421.     print 128 + 31
  2422.     next
  2423. }
  2424. /^@?_\(\.\)$/ {            # 8-bit offset from PC.
  2425.     print 128 + 12 + i
  2426.     next
  2427. }
  2428. /^@?__\(\.\)$/ {        # 16-bit offset from PC.
  2429.     print 128 + 13 + i
  2430.     next
  2431. }
  2432. /^=/ {                # Two-byte constant, in proper byte order.
  2433.     print "\\" substr($0, 2)
  2434.     print "/" substr($0, 2)
  2435.     next
  2436. }
  2437. /./ { print }            # Something else, leave untouched.
  2438. SHAR_EOF
  2439. if test 3227 -ne "`wc -c < '6809/notn'`"
  2440. then
  2441.     echo shar: error transmitting "'6809/notn'" '(should have been 3227 characters)'
  2442. fi
  2443. fi
  2444. echo shar: extracting "'6809/opgen'" '(134 characters)'
  2445. if test -f '6809/opgen'
  2446. then
  2447.     echo shar: will not over-write existing file "'6809/opgen'"
  2448. else
  2449. cat << \SHAR_EOF > '6809/opgen'
  2450. # Tool for building 6809 opcode list.
  2451. BEGIN { opno = 0 }
  2452. {
  2453.     if ($0 != "")
  2454.         for (i = 1; i <= NF; i++)
  2455.             print $i "\t" opno
  2456.     opno++
  2457. }
  2458. SHAR_EOF
  2459. if test 134 -ne "`wc -c < '6809/opgen'`"
  2460. then
  2461.     echo shar: error transmitting "'6809/opgen'" '(should have been 134 characters)'
  2462. fi
  2463. fi
  2464. echo shar: extracting "'6809/predef'" '(2672 characters)'
  2465. if test -f '6809/predef'
  2466. then
  2467.     echo shar: will not over-write existing file "'6809/predef'"
  2468. else
  2469. cat << \SHAR_EOF > '6809/predef'
  2470. neg.d    0
  2471. com.d    3
  2472. lsr.d    4
  2473. ror.d    6
  2474. asr.d    7
  2475. asl.d    8
  2476. lsl.d    8
  2477. rol.d    9
  2478. dec.d    10
  2479. inc.d    12
  2480. tst.d    13
  2481. jmp.d    14
  2482. clr.d    15
  2483. pag2    16
  2484. pag3    17
  2485. nop    18
  2486. sync    19
  2487. lbra.r    22
  2488. lbsr.r    23
  2489. daa    25
  2490. orcc.i    26
  2491. andcc.i    28
  2492. sex    29
  2493. exg    30
  2494. tfr    31
  2495. bra    32
  2496. brn    33
  2497. bhi    34
  2498. bls    35
  2499. bhs    36
  2500. bcc    36
  2501. blo    37
  2502. bcs    37
  2503. bne    38
  2504. beq    39
  2505. bvc    40
  2506. bvs    41
  2507. bpl    42
  2508. bmi    43
  2509. bge    44
  2510. blt    45
  2511. bgt    46
  2512. ble    47
  2513. leax.x    48
  2514. leay.x    49
  2515. leas.x    50
  2516. leau.x    51
  2517. pshs    52
  2518. puls    53
  2519. pshu    54
  2520. pulu    55
  2521. rts    57
  2522. abx    58
  2523. rti    59
  2524. cwai    60
  2525. mul    61
  2526. swi    63
  2527. nega    64
  2528. coma    67
  2529. lsra    68
  2530. rora    70
  2531. asra    71
  2532. asla    72
  2533. lsla    72
  2534. rola    73
  2535. deca    74
  2536. inca    76
  2537. tsta    77
  2538. clra    79
  2539. negb    80
  2540. comb    83
  2541. lsrb    84
  2542. rorb    86
  2543. asrb    87
  2544. aslb    88
  2545. lslb    88
  2546. rolb    89
  2547. decb    90
  2548. incb    92
  2549. tstb    93
  2550. clrb    95
  2551. neg.x    96
  2552. com.x    99
  2553. lsr.x    100
  2554. ror.x    102
  2555. asr.x    103
  2556. asl.x    104
  2557. lsl.x    104
  2558. rol.x    105
  2559. dec.x    106
  2560. inc.x    108
  2561. tst.x    109
  2562. jmp.x    110
  2563. clr.x    111
  2564. neg.e    112
  2565. com.e    115
  2566. lsr.e    116
  2567. ror.e    118
  2568. asr.e    119
  2569. asl.e    120
  2570. lsl.e    120
  2571. rol.e    121
  2572. dec.e    122
  2573. inc.e    124
  2574. tst.e    125
  2575. jmp.e    126
  2576. clr.e    127
  2577. suba.i    128
  2578. cmpa.i    129
  2579. sbca.i    130
  2580. subd.i    131
  2581. anda.i    132
  2582. bita.i    133
  2583. lda.i    134
  2584. eora.i    136
  2585. adca.i    137
  2586. ora.i    138
  2587. adda.i    139
  2588. cmpx.i    140
  2589. bsr    141
  2590. ldx.i    142
  2591. suba.d    144
  2592. cmpa.d    145
  2593. sbca.d    146
  2594. subd.d    147
  2595. anda.d    148
  2596. bita.d    149
  2597. lda.d    150
  2598. sta.d    151
  2599. eora.d    152
  2600. adca.d    153
  2601. ora.d    154
  2602. adda.d    155
  2603. cmpx.d    156
  2604. jsr.d    157
  2605. ldx.d    158
  2606. stx.d    159
  2607. suba.x    160
  2608. cmpa.x    161
  2609. sbca.x    162
  2610. subd.x    163
  2611. anda.x    164
  2612. bita.x    165
  2613. lda.x    166
  2614. sta.x    167
  2615. eora.x    168
  2616. adca.x    169
  2617. ora.x    170
  2618. adda.x    171
  2619. cmpx.x    172
  2620. jsr.x    173
  2621. ldx.x    174
  2622. stx.x    175
  2623. suba.e    176
  2624. cmpa.e    177
  2625. sbca.e    178
  2626. subd.e    179
  2627. anda.e    180
  2628. bita.e    181
  2629. lda.e    182
  2630. sta.e    183
  2631. eora.e    184
  2632. adca.e    185
  2633. ora.e    186
  2634. adda.e    187
  2635. cmpx.e    188
  2636. jsr.e    189
  2637. ldx.e    190
  2638. stx.e    191
  2639. subb.i    192
  2640. cmpb.i    193
  2641. sbcb.i    194
  2642. addd.i    195
  2643. andb.i    196
  2644. bitb.i    197
  2645. ldb.i    198
  2646. eorb.i    200
  2647. adcb.i    201
  2648. orb.i    202
  2649. addb.i    203
  2650. ldd.i    204
  2651. ldu.i    206
  2652. subb.d    208
  2653. cmpb.d    209
  2654. sbcb.d    210
  2655. addd.d    211
  2656. andb.d    212
  2657. bitb.d    213
  2658. ldb.d    214
  2659. stb.d    215
  2660. eorb.d    216
  2661. adcb.d    217
  2662. orb.d    218
  2663. addb.d    219
  2664. ldd.d    220
  2665. std.d    221
  2666. ldu.d    222
  2667. stu.d    223
  2668. subb.x    224
  2669. cmpb.x    225
  2670. sbcb.x    226
  2671. addd.x    227
  2672. andb.x    228
  2673. bitb.x    229
  2674. ldb.x    230
  2675. stb.x    231
  2676. eorb.x    232
  2677. adcb.x    233
  2678. orb.x    234
  2679. addb.x    235
  2680. ldd.x    236
  2681. std.x    237
  2682. ldu.x    238
  2683. stu.x    239
  2684. subb.e    240
  2685. cmpb.e    241
  2686. sbcb.e    242
  2687. addd.e    243
  2688. andb.e    244
  2689. bitb.e    245
  2690. ldb.e    246
  2691. stb.e    247
  2692. eorb.e    248
  2693. adcb.e    249
  2694. orb.e    250
  2695. addb.e    251
  2696. ldd.e    252
  2697. std.e    253
  2698. ldu.e    254
  2699. stu.e    255
  2700. lbrn    33
  2701. lbhi    34
  2702. lbls    35
  2703. lbhs    36
  2704. lbcc    36
  2705. lbcs    37
  2706. lblo    37
  2707. lbne    38
  2708. lbeq    39
  2709. lbvc    40
  2710. lbvs    41
  2711. lbpl    42
  2712. lbmi    43
  2713. lbge    44
  2714. lblt    45
  2715. lbgt    46
  2716. lble    47
  2717. swi2    63
  2718. cmpd.i    131
  2719. cmpy.i    140
  2720. ldy.i    142
  2721. cmpd.d    147
  2722. cmpy.d    156
  2723. ldy.d    158
  2724. sty.d    159
  2725. cmpd.x    163
  2726. cmpy.x    172
  2727. ldy.x    174
  2728. sty.x    175
  2729. cmpd.e    179
  2730. cmpy.e    188
  2731. ldy.e    190
  2732. sty.e    191
  2733. lds.i    206
  2734. lds.d    222
  2735. sts.d    223
  2736. lds.x    238
  2737. sts.x    239
  2738. lds.e    254
  2739. sts.e    255
  2740. swi3    63
  2741. cmpu.i    131
  2742. cmps.i    140
  2743. cmpu.d    147
  2744. cmps.d    156
  2745. cmpu.x    163
  2746. cmps.x    172
  2747. cmpu.e    179
  2748. cmps.e    188
  2749. SHAR_EOF
  2750. if test 2672 -ne "`wc -c < '6809/predef'`"
  2751. then
  2752.     echo shar: error transmitting "'6809/predef'" '(should have been 2672 characters)'
  2753. fi
  2754. fi
  2755. echo shar: extracting "'6809/Makefile'" '(140 characters)'
  2756. if test -f '6809/Makefile'
  2757. then
  2758.     echo shar: will not over-write existing file "'6809/Makefile'"
  2759. else
  2760. cat << \SHAR_EOF > '6809/Makefile'
  2761. predef:    6809.ops 6809.opsup
  2762.     ( awk -f opgen 6809.ops ; cat 6809.opsup ) >predef
  2763.  
  2764. pdcheck:    predef
  2765.     awk '{print $$1}' predef | sort | uniq -d
  2766. SHAR_EOF
  2767. if test 140 -ne "`wc -c < '6809/Makefile'`"
  2768. then
  2769.     echo shar: error transmitting "'6809/Makefile'" '(should have been 140 characters)'
  2770. fi
  2771. fi
  2772. echo shar: done with directory "'6809'"
  2773. exit 0
  2774. #    End of shell archive
  2775.